#module名称
set(MODULE_NAME "local_sensor_data_sender")

#调用函数，把src，generated的子目录分别保存在变量中,filters可用于过滤包含指定字符串的文件夹
list(APPEND filters "")
#调用函数，把src子目录保存在SRC_DIRS变量中
list_sub_dir(SRC_DIRS ${CMAKE_CURRENT_SOURCE_DIR} "${filters}")
#调用函数，把generated子目录保存在GENERATED_DIRS变量中
list_sub_dir(GENERATED_DIRS ${CMAKE_SOURCE_DIR}/generated "${filters}")

#把目录下的c和c++所有源文件分别保存在变量中
file(GLOB_RECURSE
    SOURCES
    ${CMAKE_CURRENT_SOURCE_DIR}/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/*.cxx
    ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/*.cc
    ${CMAKE_SOURCE_DIR}/generated/*.cpp)
         
OPTION(SAVE_SENDER_FILE_MACRO "Build the project using macro，save local file set as ON,otherwise set OFF" OFF)
if(SAVE_SENDER_FILE_MACRO)
    add_definitions("-DSAVE_SENDER_FILE")
else()
    remove_definitions("-DSAVE_SENDER_FILE")
endif()

#默认编译c和c++文件
add_executable(${MODULE_NAME} ${SOURCES})

#用户可在此添加编译选项
#eg: target_compile_options(${MODULE_NAME} PRIVATE -Wall USER_COMPILE_OPTIONS)
target_compile_options(${MODULE_NAME} PRIVATE -Wall)

find_package(ara-exec)
find_package(ara-core)

#camera库头文件
set(CAMERA_INCLUDE_DIRS
    ${ara-exec_INCLUDE_DIRS}
    ${ara-core_INCLUDE_DIRS})
#camera库
set(CAMERA_LIBRARIES
    ${ara-exec_LIBRARIES}
    ${ara-core_LIBRARIES}
    pthread
    yaml-cpp
    securec)

#用户可在此添加头文件路径
target_include_directories(${MODULE_NAME}   
    PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/../
    /usr/local/include/pcl-1.11/
    /usr/local/include/opencv4
    ${SRC_DIRS}
    ${GENERATED_DIRS}

    ${CAMERA_INCLUDE_DIRS})

link_directories(/usr/local/lib)

#用户可在此添加链接库
target_link_libraries(${MODULE_NAME}
    PRIVATE
    ${CAMERA_LIBRARIES}
    opencv_core
    opencv_features2d
    opencv_flann
    opencv_imgcodecs
    opencv_imgproc
    opencv_ml

    avutil
    avcodec
    avdevice 
    avfilter 
    avformat 
    swresample 
    swscale
    boost_system
    pcl_io
    pcl_common
    boost_date_time
) 
        
#用户可在此添加链接参数
#eg: set_target_properties(${MODULE_NAME} PROPERTIES LINK_FLAGS "-Wl,--as-needed USER_LINK_OPTIONS")
set_target_properties(${MODULE_NAME} PROPERTIES LINK_FLAGS "-Wl,--as-needed")
